property_exists
အရာဝတ်ထုတစ်ခုသို့မဟုတ်အတန်းအစားသည်ဤပိုင်ဆိုင်မှုရှိ,
function name: Property_exists ()
function ကိုဖော်ပြချက်: Monthent_exists () function ကို) အရာဝတ်ထုတစ်ခုသို့မဟုတ်အတန်းအစားသည်သတ်မှတ်ထားသော attribute ကိုရှိမရှိစစ်ဆေးသည်။
Parametermer
Value ကိုပြန်သွားပါ
သက်ဆိုင်သောဗားရှင်း - PHP 4, PHP 5, PHP 7
အသုံးပြုမှုဥပမာ -
class MyClass { public $name = "John"; private $age = 25; } $object = new MyClass(); if (property_exists($object, 'name')) { echo "The 'name' property exists."; } else { echo "The 'name' property does not exist."; } // 输出:The 'name' property exists.
class MyClass { public $name = "John"; private $age = 25; } $object = new MyClass(); if (property_exists($object, 'age')) { echo "The 'age' property exists."; } else { echo "The 'age' property does not exist."; } // 输出:The 'age' property does not exist.
class MyClass { public static $name = "John"; private static $age = 25; } if (property_exists('MyClass', 'name')) { echo "The 'name' static property exists."; } else { echo "The 'name' static property does not exist."; } // 输出:The 'name' static property exists.
class MyClass { public static $name = "John"; private static $age = 25; } if (property_exists('MyClass', 'age')) { echo "The 'age' static property exists."; } else { echo "The 'age' static property does not exist."; } // 输出:The 'age' static property does not exist.